package com.codescholar.jdbctemplate;

import com.codescholar.utils.JDBCUtils;
import org.springframework.jdbc.core.JdbcTemplate;

import java.sql.Timestamp;

/**
 * JdbcTemplate入门
 */
public class JdbcTemplateDemo1 {

    public static void main(String[] args) {
        Timestamp createTime = new Timestamp(System.currentTimeMillis());
        Timestamp updateTime = new Timestamp(System.currentTimeMillis());

        //1.导入jar包
        //2.创建JDBCTemplate对象
        JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
        //3.调用方法
        String sql = "insert into e_exercise(answer, create_time, question, update_time, views, type_id, user_id) values( ?, ?, ?, ?, 0, 2, 1)";
        //String sql = "insert into e_type(id, name) values(21, 'aaa')";
        int count = template.update(sql, "aaa", createTime, "bbb", updateTime);
        System.out.println(count);
    }
}
